3.74 \(\int \frac{A+B \tan (e+f x)+C \tan ^2(e+f x)}{(a+b \tan (e+f x)) (c+d \tan (e+f x))} \, dx\)

Optimal. Leaf size=165 \[ \frac{x (a (A c+B d-c C)+b (B c-d (A-C)))}{\left (a^2+b^2\right ) \left (c^2+d^2\right )}+\frac{\left (A b^2-a (b B-a C)\right ) \log (a \cos (e+f x)+b \sin (e+f x))}{f \left (a^2+b^2\right ) (b c-a d)}-\frac{\left (A d^2-B c d+c^2 C\right ) \log (c \cos (e+f x)+d \sin (e+f x))}{f \left (c^2+d^2\right ) (b c-a d)} \]

[Out]

((a*(A*c - c*C + B*d) + b*(B*c - (A - C)*d))*x)/((a^2 + b^2)*(c^2 + d^2)) + ((A*b^2 - a*(b*B - a*C))*Log[a*Cos
[e + f*x] + b*Sin[e + f*x]])/((a^2 + b^2)*(b*c - a*d)*f) - ((c^2*C - B*c*d + A*d^2)*Log[c*Cos[e + f*x] + d*Sin
[e + f*x]])/((b*c - a*d)*(c^2 + d^2)*f)

________________________________________________________________________________________

Rubi [A]  time = 0.256364, antiderivative size = 164, normalized size of antiderivative = 0.99, number of steps used = 3, number of rules used = 2, integrand size = 45, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.044, Rules used = {3651, 3530} \[ \frac{x (a (A c+B d-c C)-b d (A-C)+b B c)}{\left (a^2+b^2\right ) \left (c^2+d^2\right )}+\frac{\left (A b^2-a (b B-a C)\right ) \log (a \cos (e+f x)+b \sin (e+f x))}{f \left (a^2+b^2\right ) (b c-a d)}-\frac{\left (A d^2-B c d+c^2 C\right ) \log (c \cos (e+f x)+d \sin (e+f x))}{f \left (c^2+d^2\right ) (b c-a d)} \]

Antiderivative was successfully verified.

[In]

Int[(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)/((a + b*Tan[e + f*x])*(c + d*Tan[e + f*x])),x]

[Out]

((b*B*c - b*(A - C)*d + a*(A*c - c*C + B*d))*x)/((a^2 + b^2)*(c^2 + d^2)) + ((A*b^2 - a*(b*B - a*C))*Log[a*Cos
[e + f*x] + b*Sin[e + f*x]])/((a^2 + b^2)*(b*c - a*d)*f) - ((c^2*C - B*c*d + A*d^2)*Log[c*Cos[e + f*x] + d*Sin
[e + f*x]])/((b*c - a*d)*(c^2 + d^2)*f)

Rule 3651

Int[((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2)/(((a_) + (b_.)*tan[(e_.) + (f_.)
*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])), x_Symbol] :> Simp[((a*(A*c - c*C + B*d) + b*(B*c - A*d + C*d
))*x)/((a^2 + b^2)*(c^2 + d^2)), x] + (Dist[(A*b^2 - a*b*B + a^2*C)/((b*c - a*d)*(a^2 + b^2)), Int[(b - a*Tan[
e + f*x])/(a + b*Tan[e + f*x]), x], x] - Dist[(c^2*C - B*c*d + A*d^2)/((b*c - a*d)*(c^2 + d^2)), Int[(d - c*Ta
n[e + f*x])/(c + d*Tan[e + f*x]), x], x]) /; FreeQ[{a, b, c, d, e, f, A, B, C}, x] && NeQ[b*c - a*d, 0] && NeQ
[a^2 + b^2, 0] && NeQ[c^2 + d^2, 0]

Rule 3530

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c*Log[Re
moveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]])/(b*f), x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d,
0] && NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]

Rubi steps

\begin{align*} \int \frac{A+B \tan (e+f x)+C \tan ^2(e+f x)}{(a+b \tan (e+f x)) (c+d \tan (e+f x))} \, dx &=\frac{(b B c-b (A-C) d+a (A c-c C+B d)) x}{\left (a^2+b^2\right ) \left (c^2+d^2\right )}+\frac{\left (A b^2-a (b B-a C)\right ) \int \frac{b-a \tan (e+f x)}{a+b \tan (e+f x)} \, dx}{\left (a^2+b^2\right ) (b c-a d)}-\frac{\left (c^2 C-B c d+A d^2\right ) \int \frac{d-c \tan (e+f x)}{c+d \tan (e+f x)} \, dx}{(b c-a d) \left (c^2+d^2\right )}\\ &=\frac{(b B c-b (A-C) d+a (A c-c C+B d)) x}{\left (a^2+b^2\right ) \left (c^2+d^2\right )}+\frac{\left (A b^2-a (b B-a C)\right ) \log (a \cos (e+f x)+b \sin (e+f x))}{\left (a^2+b^2\right ) (b c-a d) f}-\frac{\left (c^2 C-B c d+A d^2\right ) \log (c \cos (e+f x)+d \sin (e+f x))}{(b c-a d) \left (c^2+d^2\right ) f}\\ \end{align*}

Mathematica [A]  time = 1.52495, size = 313, normalized size = 1.9 \[ -\frac{\frac{\log \left (\sqrt{-b^2}-b \tan (e+f x)\right ) \left (\frac{\sqrt{-b^2} (a (A c+B d-c C)+b d (C-A)+b B c)}{b}+a A d-a B c-a C d+A b c+b B d-b c C\right )}{\left (a^2+b^2\right ) \left (c^2+d^2\right )}+\frac{\log \left (\sqrt{-b^2}+b \tan (e+f x)\right ) \left (\frac{b (a (A c+B d-c C)+b d (C-A)+b B c)}{\sqrt{-b^2}}+a A d-a B c-a C d+A b c+b B d-b c C\right )}{\left (a^2+b^2\right ) \left (c^2+d^2\right )}+\frac{2 \left (a (a C-b B)+A b^2\right ) \log (a+b \tan (e+f x))}{\left (a^2+b^2\right ) (a d-b c)}+\frac{2 \left (A d^2-B c d+c^2 C\right ) \log (c+d \tan (e+f x))}{\left (c^2+d^2\right ) (b c-a d)}}{2 f} \]

Antiderivative was successfully verified.

[In]

Integrate[(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)/((a + b*Tan[e + f*x])*(c + d*Tan[e + f*x])),x]

[Out]

-(((A*b*c - a*B*c - b*c*C + a*A*d + b*B*d - a*C*d + (Sqrt[-b^2]*(b*B*c + b*(-A + C)*d + a*(A*c - c*C + B*d)))/
b)*Log[Sqrt[-b^2] - b*Tan[e + f*x]])/((a^2 + b^2)*(c^2 + d^2)) + (2*(A*b^2 + a*(-(b*B) + a*C))*Log[a + b*Tan[e
 + f*x]])/((a^2 + b^2)*(-(b*c) + a*d)) + ((A*b*c - a*B*c - b*c*C + a*A*d + b*B*d - a*C*d + (b*(b*B*c + b*(-A +
 C)*d + a*(A*c - c*C + B*d)))/Sqrt[-b^2])*Log[Sqrt[-b^2] + b*Tan[e + f*x]])/((a^2 + b^2)*(c^2 + d^2)) + (2*(c^
2*C - B*c*d + A*d^2)*Log[c + d*Tan[e + f*x]])/((b*c - a*d)*(c^2 + d^2)))/(2*f)

________________________________________________________________________________________

Maple [B]  time = 0.076, size = 647, normalized size = 3.9 \begin{align*} \text{result too large to display} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(a+b*tan(f*x+e))/(c+d*tan(f*x+e)),x)

[Out]

-1/2/f/(c^2+d^2)/(a^2+b^2)*ln(1+tan(f*x+e)^2)*A*a*d-1/2/f/(c^2+d^2)/(a^2+b^2)*ln(1+tan(f*x+e)^2)*A*b*c+1/2/f/(
c^2+d^2)/(a^2+b^2)*ln(1+tan(f*x+e)^2)*B*a*c-1/2/f/(c^2+d^2)/(a^2+b^2)*ln(1+tan(f*x+e)^2)*B*b*d+1/2/f/(c^2+d^2)
/(a^2+b^2)*ln(1+tan(f*x+e)^2)*a*C*d+1/2/f/(c^2+d^2)/(a^2+b^2)*ln(1+tan(f*x+e)^2)*C*b*c+1/f/(c^2+d^2)/(a^2+b^2)
*A*arctan(tan(f*x+e))*a*c-1/f/(c^2+d^2)/(a^2+b^2)*A*arctan(tan(f*x+e))*b*d+1/f/(c^2+d^2)/(a^2+b^2)*B*arctan(ta
n(f*x+e))*a*d+1/f/(c^2+d^2)/(a^2+b^2)*B*arctan(tan(f*x+e))*b*c-1/f/(c^2+d^2)/(a^2+b^2)*C*arctan(tan(f*x+e))*a*
c+1/f/(c^2+d^2)/(a^2+b^2)*C*arctan(tan(f*x+e))*b*d+1/f/(a*d-b*c)/(c^2+d^2)*ln(c+d*tan(f*x+e))*A*d^2-1/f/(a*d-b
*c)/(c^2+d^2)*ln(c+d*tan(f*x+e))*B*c*d+1/f/(a*d-b*c)/(c^2+d^2)*ln(c+d*tan(f*x+e))*c^2*C-1/f/(a*d-b*c)/(a^2+b^2
)*ln(a+b*tan(f*x+e))*A*b^2+1/f/(a*d-b*c)/(a^2+b^2)*ln(a+b*tan(f*x+e))*B*a*b-1/f/(a*d-b*c)/(a^2+b^2)*ln(a+b*tan
(f*x+e))*C*a^2

________________________________________________________________________________________

Maxima [A]  time = 1.49136, size = 328, normalized size = 1.99 \begin{align*} \frac{\frac{2 \,{\left ({\left ({\left (A - C\right )} a + B b\right )} c +{\left (B a -{\left (A - C\right )} b\right )} d\right )}{\left (f x + e\right )}}{{\left (a^{2} + b^{2}\right )} c^{2} +{\left (a^{2} + b^{2}\right )} d^{2}} + \frac{2 \,{\left (C a^{2} - B a b + A b^{2}\right )} \log \left (b \tan \left (f x + e\right ) + a\right )}{{\left (a^{2} b + b^{3}\right )} c -{\left (a^{3} + a b^{2}\right )} d} - \frac{2 \,{\left (C c^{2} - B c d + A d^{2}\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{b c^{3} - a c^{2} d + b c d^{2} - a d^{3}} + \frac{{\left ({\left (B a -{\left (A - C\right )} b\right )} c -{\left ({\left (A - C\right )} a + B b\right )} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{{\left (a^{2} + b^{2}\right )} c^{2} +{\left (a^{2} + b^{2}\right )} d^{2}}}{2 \, f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(a+b*tan(f*x+e))/(c+d*tan(f*x+e)),x, algorithm="maxima")

[Out]

1/2*(2*(((A - C)*a + B*b)*c + (B*a - (A - C)*b)*d)*(f*x + e)/((a^2 + b^2)*c^2 + (a^2 + b^2)*d^2) + 2*(C*a^2 -
B*a*b + A*b^2)*log(b*tan(f*x + e) + a)/((a^2*b + b^3)*c - (a^3 + a*b^2)*d) - 2*(C*c^2 - B*c*d + A*d^2)*log(d*t
an(f*x + e) + c)/(b*c^3 - a*c^2*d + b*c*d^2 - a*d^3) + ((B*a - (A - C)*b)*c - ((A - C)*a + B*b)*d)*log(tan(f*x
 + e)^2 + 1)/((a^2 + b^2)*c^2 + (a^2 + b^2)*d^2))/f

________________________________________________________________________________________

Fricas [A]  time = 2.4913, size = 633, normalized size = 3.84 \begin{align*} \frac{2 \,{\left ({\left ({\left (A - C\right )} a b + B b^{2}\right )} c^{2} -{\left ({\left (A - C\right )} a^{2} +{\left (A - C\right )} b^{2}\right )} c d -{\left (B a^{2} -{\left (A - C\right )} a b\right )} d^{2}\right )} f x +{\left ({\left (C a^{2} - B a b + A b^{2}\right )} c^{2} +{\left (C a^{2} - B a b + A b^{2}\right )} d^{2}\right )} \log \left (\frac{b^{2} \tan \left (f x + e\right )^{2} + 2 \, a b \tan \left (f x + e\right ) + a^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) -{\left ({\left (C a^{2} + C b^{2}\right )} c^{2} -{\left (B a^{2} + B b^{2}\right )} c d +{\left (A a^{2} + A b^{2}\right )} d^{2}\right )} \log \left (\frac{d^{2} \tan \left (f x + e\right )^{2} + 2 \, c d \tan \left (f x + e\right ) + c^{2}}{\tan \left (f x + e\right )^{2} + 1}\right )}{2 \,{\left ({\left (a^{2} b + b^{3}\right )} c^{3} -{\left (a^{3} + a b^{2}\right )} c^{2} d +{\left (a^{2} b + b^{3}\right )} c d^{2} -{\left (a^{3} + a b^{2}\right )} d^{3}\right )} f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(a+b*tan(f*x+e))/(c+d*tan(f*x+e)),x, algorithm="fricas")

[Out]

1/2*(2*(((A - C)*a*b + B*b^2)*c^2 - ((A - C)*a^2 + (A - C)*b^2)*c*d - (B*a^2 - (A - C)*a*b)*d^2)*f*x + ((C*a^2
 - B*a*b + A*b^2)*c^2 + (C*a^2 - B*a*b + A*b^2)*d^2)*log((b^2*tan(f*x + e)^2 + 2*a*b*tan(f*x + e) + a^2)/(tan(
f*x + e)^2 + 1)) - ((C*a^2 + C*b^2)*c^2 - (B*a^2 + B*b^2)*c*d + (A*a^2 + A*b^2)*d^2)*log((d^2*tan(f*x + e)^2 +
 2*c*d*tan(f*x + e) + c^2)/(tan(f*x + e)^2 + 1)))/(((a^2*b + b^3)*c^3 - (a^3 + a*b^2)*c^2*d + (a^2*b + b^3)*c*
d^2 - (a^3 + a*b^2)*d^3)*f)

________________________________________________________________________________________

Sympy [F(-1)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)**2)/(a+b*tan(f*x+e))/(c+d*tan(f*x+e)),x)

[Out]

Timed out

________________________________________________________________________________________

Giac [A]  time = 1.72128, size = 367, normalized size = 2.22 \begin{align*} \frac{\frac{2 \,{\left (A a c - C a c + B b c + B a d - A b d + C b d\right )}{\left (f x + e\right )}}{a^{2} c^{2} + b^{2} c^{2} + a^{2} d^{2} + b^{2} d^{2}} + \frac{{\left (B a c - A b c + C b c - A a d + C a d - B b d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{a^{2} c^{2} + b^{2} c^{2} + a^{2} d^{2} + b^{2} d^{2}} + \frac{2 \,{\left (C a^{2} b - B a b^{2} + A b^{3}\right )} \log \left ({\left | b \tan \left (f x + e\right ) + a \right |}\right )}{a^{2} b^{2} c + b^{4} c - a^{3} b d - a b^{3} d} - \frac{2 \,{\left (C c^{2} d - B c d^{2} + A d^{3}\right )} \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{b c^{3} d - a c^{2} d^{2} + b c d^{3} - a d^{4}}}{2 \, f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(a+b*tan(f*x+e))/(c+d*tan(f*x+e)),x, algorithm="giac")

[Out]

1/2*(2*(A*a*c - C*a*c + B*b*c + B*a*d - A*b*d + C*b*d)*(f*x + e)/(a^2*c^2 + b^2*c^2 + a^2*d^2 + b^2*d^2) + (B*
a*c - A*b*c + C*b*c - A*a*d + C*a*d - B*b*d)*log(tan(f*x + e)^2 + 1)/(a^2*c^2 + b^2*c^2 + a^2*d^2 + b^2*d^2) +
 2*(C*a^2*b - B*a*b^2 + A*b^3)*log(abs(b*tan(f*x + e) + a))/(a^2*b^2*c + b^4*c - a^3*b*d - a*b^3*d) - 2*(C*c^2
*d - B*c*d^2 + A*d^3)*log(abs(d*tan(f*x + e) + c))/(b*c^3*d - a*c^2*d^2 + b*c*d^3 - a*d^4))/f